package com.gzmu.storage.controller;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.gzmu.storage.entity.Station;
import com.gzmu.storage.service.AdminlogService;
import com.gzmu.storage.service.StationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaobo Yan
 * @since 2020-04-16
 */
@Controller
@RequestMapping("/station")
public class StationController {
    @Autowired
    private StationService stationService;

    @Autowired
    private AdminlogService adminlogService;
    @ResponseBody
    @RequestMapping("addStation")
    public Object addStation(Station station){
        Map map = new HashMap<>();
        Date date = new Date(  );
        station.setCreatetime( date );
        station.setUpdatetime( date );
        station.setRemark( "派出所" );
//        station.setStatus( 0 );
        boolean b = stationService.insertAndUpdate( station );
         adminlogService.insertAdminlog("添加" + station.getName() + "派出所");
        map.put( "code", b);
        return JSONObject.toJSON(map);
    }
}

